package com.hzhr.iot.device.dao;

import com.hzhr.iot.device.dao.mapper.custom.DeviceMaintenanceCardEntityCustomMapper;
import com.hzhr.iot.device.dao.mapper.generator.DeviceMaintenanceCardEntityMapper;
import com.hzhr.iot.device.entity.DeviceMaintenanceCardEntity;
import com.hzhr.iot.device.entity.ext.DeviceMaintenanceCardEntityExt;
import com.hzhr.iot.device.queryModel.custom.DeviceMaintenanceCardCustomQueryModel;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import java.util.ArrayList;
import java.util.List;

@Repository
public class DeviceMaintenanceCardDao {
    @Autowired
    DeviceMaintenanceCardEntityMapper deviceMaintenanceCardEntityMapper;
    @Autowired
    DeviceMaintenanceCardEntityCustomMapper deviceMaintenanceCardEntityCustomMapper;

    public int insert(DeviceMaintenanceCardEntity record) {
        if (record == null) return 0;
        int changeCount = deviceMaintenanceCardEntityMapper.insert(record);
        return changeCount;
    }

    public int delete(DeviceMaintenanceCardCustomQueryModel queryModel) {
        if (queryModel == null) return 0;
        int changeCount = deviceMaintenanceCardEntityCustomMapper.delete(queryModel);
        return changeCount;
    }

    public int update(DeviceMaintenanceCardEntity record) {
        if (record == null) return 0;
        int changeCount = deviceMaintenanceCardEntityMapper.updateByPrimaryKey(record);
        return changeCount;
    }

    public int updateProps(DeviceMaintenanceCardCustomQueryModel queryModel) {
        if (queryModel == null) return 0;
        int changeCount = deviceMaintenanceCardEntityCustomMapper.updateProps(queryModel);
        return changeCount;
    }

    public DeviceMaintenanceCardEntity selectEntity(DeviceMaintenanceCardCustomQueryModel queryModel) {
        if (queryModel == null) return null;
        List<DeviceMaintenanceCardEntityExt> extList = deviceMaintenanceCardEntityCustomMapper.selectExt(queryModel);
        return extList.get(0);
    }
    public List<DeviceMaintenanceCardEntity> selectEntityList(DeviceMaintenanceCardCustomQueryModel queryModel) {
        if (queryModel == null) return null;
        List<DeviceMaintenanceCardEntityExt> extList = deviceMaintenanceCardEntityCustomMapper.selectExt(queryModel);
        if (extList == null) return null;
        List<DeviceMaintenanceCardEntity> entityList = new ArrayList<>();
        for (DeviceMaintenanceCardEntity ext : extList) {
            entityList.add(ext);
        }
        return entityList;
    }

    public DeviceMaintenanceCardEntityExt selectExt(DeviceMaintenanceCardCustomQueryModel queryModel) {
        if (queryModel == null) return null;
        List<DeviceMaintenanceCardEntityExt> extList = deviceMaintenanceCardEntityCustomMapper.selectExt(queryModel);
        if (extList == null || extList.size() == 0) return null;
        return extList.get(0);
    }
    public List<DeviceMaintenanceCardEntityExt> selectExtList(DeviceMaintenanceCardCustomQueryModel queryModel) {
        if (queryModel == null) return null;
        List<DeviceMaintenanceCardEntityExt> extList = deviceMaintenanceCardEntityCustomMapper.selectExt(queryModel);
        return extList;
    }

    public DeviceMaintenanceCardEntityExt selectExt1(DeviceMaintenanceCardCustomQueryModel queryModel) {
        if (queryModel == null) return null;
        List<DeviceMaintenanceCardEntityExt> extList = deviceMaintenanceCardEntityCustomMapper.selectExt1(queryModel);
        if (extList == null || extList.size() == 0) return null;
        return extList.get(0);
    }


    // 自定义or查询
    public List<DeviceMaintenanceCardEntityExt> selectExtList1(DeviceMaintenanceCardCustomQueryModel queryModel) {
        if (queryModel == null) return null;
        List<DeviceMaintenanceCardEntityExt> extList = deviceMaintenanceCardEntityCustomMapper.selectExt1(queryModel);
        return extList;
    }

    public int selectCount(DeviceMaintenanceCardCustomQueryModel queryModel) {
        if (queryModel == null) return 0;
        int count = deviceMaintenanceCardEntityCustomMapper.selectCount(queryModel);
        return count;
    }







}
